<?php $view->extend('FrontBundle:Layout:layout.html.php') ?>

<script type="text/javascript">
      google.load("visualization", "1", {packages:["corechart"]});
      google.setOnLoadCallback(drawChart);


      function drawChart() {

      	var dataTable = new Array;

      	// get Data 
      	$.ajax({
      		async: false,
      		url: "/api/get/<?=$chart_name?>", 
      		dataType: "json", 
      		type: "GET", 
      		success: function(data){
      			for (var i in data.logs){
      				var log = data.logs[i];
      				dataTable.push(new Array(log.date, parseInt(log.value)));
      			}
      		}
      	});

      	var data = new google.visualization.DataTable();
      	data.addColumn('string', "Date"); 
		    data.addColumn('number', "<?=$chart_name?>");
		    data.addRows(dataTable);

        var options = {
          isStacked: true,
          vAxis: {
            minValue: 0, 
            maxValue: 30
          },
          legend: {position: 'none'}
        };

        var chart = new google.visualization.LineChart(document.getElementById('chart_div'));
        chart.draw(data, options);
      }
    </script>



<div data-role="page" id="one">
	<div data-role="header">
		<a href="/" data-icon="home" class="ui-btn-left">Accueil</a>
		<h1> Statistiques </h1>
	</div><!-- /header -->

	<div data-role="content" >	
		<div id="chart_div" style="width: 100%; height: 400px"></div>

		
	</div><!-- /content -->
</div><!-- /page one -->